<script lang="ts" setup>
import { useUserStore } from '@/utils/pinia'
import type { UserStore } from '@/utils/pinia'
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'

const userStore: UserStore = useUserStore()

// App 启动时
onLaunch(() => {
	console.log('App Launch')
	// 检查登录状态
	const token = userStore.token
	console.log(userStore.token)
	
	if (!token) {
		// 未登录，跳转到登录页
		uni.reLaunch({
			url: '/pageSign/login'
		})
	} else {
		// 已登录，跳转到首页
		uni.reLaunch({
			url: '/pages/index/index'
		})
	}
})

// App 显示时
onShow(() => {
	console.log('App Show')
})

// App 隐藏时
onHide(() => {
	console.log('App Hide')
})
</script>

<style>
	/*每个页面公共css */
	@import '@/static/iconfont/iconfont.css';
	@import '@/static/style.scss';
</style>
